package com.zhiwang.planet.widget.highlight

import android.graphics.RectF


class CenterPosCallback(var width: Int, var height: Int) : HighLight.OnPosCallback {

    override fun getPos(rightMargin: Float, bottomMargin: Float, rectF: RectF, marginInfo: HighLight.MarginInfo) {

        val parentWidth = rectF.width()
        val parentHeight = rectF.height()

        val left = (parentWidth - width) / 2
        val top = (parentHeight - height) / 2
        val right = parentWidth - left - width
        val bottom = parentHeight - top - height

        marginInfo.rightMargin = right + rightMargin
        marginInfo.bottomMargin = bottom + bottomMargin
    }
}